//
//  AlertController.m
//  充电桩
//
//  Created by 王开政 on 2018/3/12.
//  Copyright © 2018年 李超杰. All rights reserved.
//
#define screenWidth [[UIScreen mainScreen] bounds].size.width
#define screenHeight [[UIScreen mainScreen] bounds].size.height

#import "AlertController.h"

@implementation AlertController

-(id)initFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    self.backgroundColor = [UIColor clearColor];
    
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 50, screenWidth, 0.5)];
    line.backgroundColor =  [UIColor colorWithHexString:@"#E5E5E5"];
    
    UIView *butView = [[UIView alloc]initWithFrame:CGRectMake(10, 0, screenWidth-20, 100)];
    butView.backgroundColor = [UIColor whiteColor];
    
    butView.layer.masksToBounds = YES;
    butView.layer.cornerRadius = 10;
    [butView addSubview:self.sheetBut1];
    [butView addSubview:self.sheetBut2];
    [butView addSubview:line];
    
    
    [self addSubview:butView];
    
    [self addSubview:self.cancelBtn];
   
    
    return  self;
    
}
-(UIButton *)sheetBut1
{
    if (!_sheetBut1) {
        _sheetBut1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, screenWidth-20, 50)];
        [_sheetBut1 setTitle:@"男" forState:0];
        _sheetBut1.tag = 101;
        [_sheetBut1 setImage:[UIImage imageNamed:@"male"] forState:UIControlStateNormal];
        [_sheetBut1 setImageEdgeInsets:UIEdgeInsetsMake(0, 70, 0, 100)];
        [_sheetBut1 setTitleColor:[UIColor blackColor] forState:0];
        [_sheetBut1 addTarget:self action:@selector(sheetAc:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _sheetBut1;
}
-(UIButton *)sheetBut2
{
    if (!_sheetBut2) {
        _sheetBut2 = [[UIButton alloc]initWithFrame:CGRectMake(0, 50, screenWidth-20, 50)];
        [_sheetBut2 setTitle:@"女" forState:0];
        _sheetBut2.tag = 102;
        [_sheetBut2 setImage:[UIImage imageNamed:@"female"] forState:UIControlStateNormal];
        [_sheetBut2 setImageEdgeInsets:UIEdgeInsetsMake(0, 70, 0, 100)];
        [_sheetBut2 setTitleColor:[UIColor blackColor] forState:0];
        [_sheetBut2 addTarget:self action:@selector(sheetAc:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _sheetBut2;
}
-(UIButton *)cancelBtn
{
    if (!_cancelBtn) {
        _cancelBtn = [[UIButton alloc]initWithFrame:CGRectMake(10, 110, screenWidth-20, 50)];
        _cancelBtn.backgroundColor = [UIColor whiteColor];
        [_cancelBtn setTitle:@"取消" forState:0];
        _cancelBtn.tag = 100;
        [_cancelBtn setTitleColor:[UIColor blackColor] forState:0];
        _cancelBtn.layer.masksToBounds = YES;
        _cancelBtn.layer.cornerRadius = 10;
        [_cancelBtn addTarget:self action:@selector(sheetAc:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _cancelBtn;
}
-(void)sheetAc:(UIButton *)sender
{
    __weak typeof(self) weakself = self;
    
    if (weakself.sheetPress) {
        
        weakself.sheetPress(sender.tag);
    }

    
}
@end
